import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		Token: "",
		UserId: "",
		userName: "", // 昵称
		userImg: "", // 头像
		// TelephoneNumber: "", // 电话号码 (String)
		userType: 0, // 用户类型：0会员 1核销员
		userState: 0, // 用户状态：0无邀请码 1无邀请码激活 2有邀请码 3有邀请码激活 (Int32) 4 未授权
		InviteCode: "",
		scalesCode: {}
	},
	mutations: {
		loginFront(state, data) {
			// console.log(data)
			state.userName = data.nickName;
			state.userImg = data.avatarUrl;
		},
		loginBack(state, data) {
			// console.log(data)
			state.Token = data.Token;
			state.UserId = data.UserId;
			state.userType = data.UserType;
			state.userState = data.UserState;
			state.InviteCode = data.InviteCode;
			// console.log(state)
		},
		userStateChange(state, userState) {
			state.userState = userState;
		},
		userTypeChange(state, userType) {
			state.userType = userType;
		},
		setInviteCode(state, InviteCode) {
			state.InviteCode = InviteCode;
		},
	}
})

export default store
